#ifndef _ODN_RENDERER_H
#define _ODN_RENDERER_H

#include "odn_Element.h"

//OpenGL headers
#include <gl\gl.h>			// Header File For The OpenGL32 Library
#include <gl\glu.h>			// Header File For The GLu32 Library
//#include <gl\glaux.h>		// Header File For The Glaux Library

//Standard library headers
#include <windows.h>

namespace ouden
{
	namespace gfx
	{
	
		//Window callback
		LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window
									UINT	uMsg,			// Message For This Window
									WPARAM	wParam,			// Additional Message Information
									LPARAM	lParam);		// Additional Message Information
		
		class ODN_Renderer //: public ODN_Element
		{
			
			public:
				
				//Constructor and destructor
				//TODO: Check these 
			    ODN_Renderer() 			{ active=TRUE; fullscreen=TRUE; hDC=NULL; hRC=NULL; hWnd=NULL; }
				~ODN_Renderer() 		{ if (hWnd) KillWindow(); } //TODO: Check if needed here or after main loop
				
				//Main functions
				bool 	CreateRendererWindow(char* Title, int Width, int Height, int Bits, bool Fullscreen);
				void 	ResizeScene(int Width, int Height);
				void 	KillWindow();
				bool 	DrawScene();
				
				bool	CheckMessages();
				
				//Variable access functions
				unsigned int 	getWidth()				{ return width; }
				unsigned int 	getHeight()				{ return height; }
				HWND 			getWindowHandle()		{ return hWnd; }
				HDC				gethDC()				{ return hDC; }
				bool 			isActive()				{ return active; }
				void			setActive(bool value)	{ active = value; }
				bool 			isQuit()				{ return quit; }
				void		 	setQuit(bool value)		{ quit = value; }
				
				//Rendering functions 
				//void drawVertexList(ODN_Vertex* vertices, int vertexcount
				
			private:
				
				//General variables
				bool 			fullscreen;
				unsigned int 	width;
				unsigned int 	height;
				
				//Window variables
				HGLRC		hRC;		// Permanent Rendering Context
				HWND		hWnd;		// Holds Our Window Handle
				HINSTANCE	hInstance;	// Holds The Instance Of The Application
				HDC				hDC;		//Private GDI Device Context
				bool 			active;		//Is the windows active?
				bool 			quit;		//Have we received a quit message? 
				
				//Renderer initialisation
				bool 	Init();
			
		};
		
	} //namespace gfx
} //namespace ouden

#endif //_ODN_RENDERER_H
